package com.mine.redis.util.controller;

import com.mine.redis.util.service.CouponService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author weixiao
 * @date 2024/8/16 13:59
 */
@RestController
@Slf4j
@RequestMapping("/coupon")
public class CouponController {

    @Autowired
    private CouponService couponService;

    /**
     * 优惠券秒杀接口
     *
     * @param userId 用户id
     * @param couponId 优惠券id
     */
    @PostMapping("/secKill")
    public void secKill(@RequestParam("userId") Integer userId, @RequestParam("couponId") Integer couponId) {
        couponService.secKillWithLua(userId, couponId);
    }
}
